/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Main;

import java.awt.HeadlessException;
import java.awt.event.KeyEvent;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

/**
 *
 * @author anas
 */
public class Modifier extends javax.swing.JInternalFrame {

    Connection conn= null;
    ResultSet rs = null;
    PreparedStatement ps =null;
    
    
    public Modifier() {
        initComponents();
        conn = gestion_chambes_hotel.Gestion_Chambes_Hotel.DB_Connection();
        visibility();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        CIN = new javax.swing.JTextField();
        affi = new javax.swing.JLabel();
        cin = new javax.swing.JLabel();
        nom = new javax.swing.JLabel();
        prenom = new javax.swing.JLabel();
        num = new javax.swing.JLabel();
        email = new javax.swing.JLabel();
        marier = new javax.swing.JLabel();
        CIN_Client = new javax.swing.JTextField();
        Nom_Client = new javax.swing.JTextField();
        Prenom_Client = new javax.swing.JTextField();
        Numero_Tele_Client = new javax.swing.JTextField();
        Email_Client = new javax.swing.JTextField();
        oui = new javax.swing.JRadioButton();
        non = new javax.swing.JRadioButton();
        metier = new javax.swing.JLabel();
        date = new javax.swing.JLabel();
        nom_en = new javax.swing.JLabel();
        Metier_Client = new javax.swing.JTextField();
        Date_Naissance_Client = new com.toedter.calendar.JDateChooser();
        Nombre_Enfant_Client = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        Enre = new javax.swing.JLabel();
        cin_ar = new javax.swing.JLabel();
        nom_ar = new javax.swing.JLabel();
        afficher_ar = new javax.swing.JLabel();
        prenom_ar = new javax.swing.JLabel();
        num_ar = new javax.swing.JLabel();
        email_ar = new javax.swing.JLabel();
        afficher_ar_back = new javax.swing.JLabel();
        metier_ar = new javax.swing.JLabel();
        date_ar = new javax.swing.JLabel();
        nom_en_ar = new javax.swing.JLabel();
        enregistrer_ar = new javax.swing.JLabel();
        marier_ar = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        Etage_Chambre_Client = new javax.swing.JComboBox();
        Nom_Personne = new javax.swing.JComboBox();
        Num_Chambre = new javax.swing.JComboBox();
        Etage_Chambre = new javax.swing.JLabel();
        Nombre_Personnes = new javax.swing.JLabel();
        Numero_Chambre = new javax.swing.JLabel();
        etage = new javax.swing.JLabel();
        nom_per = new javax.swing.JLabel();
        num_ch = new javax.swing.JLabel();
        montant = new javax.swing.JLabel();
        txt1 = new javax.swing.JLabel();
        txt2 = new javax.swing.JLabel();
        TXT_MESSAGE = new javax.swing.JLabel();
        enre = new javax.swing.JLabel();
        jLabel41 = new javax.swing.JLabel();
        enre_back = new javax.swing.JLabel();
        txt4 = new javax.swing.JLabel();
        txt3 = new javax.swing.JLabel();
        etage_ar = new javax.swing.JLabel();
        nom_per_ar = new javax.swing.JLabel();
        enr = new javax.swing.JLabel();
        num_ch_ar = new javax.swing.JLabel();
        montant_ar = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();

        setBorder(null);
        setClosable(true);
        setIconifiable(true);
        setMaximizable(true);
        setTitle("                                                                               Modifications                                                                                                               "); // NOI18N
        setMaximumSize(new java.awt.Dimension(894, 555));
        setMinimumSize(new java.awt.Dimension(894, 555));
        setPreferredSize(new java.awt.Dimension(894, 555));

        jTabbedPane1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jTabbedPane1.setForeground(new java.awt.Color(0, 102, 153));

        jPanel1.setLayout(null);

        CIN.setText("Entrer le CIN ici ...");
        CIN.setBorder(null);
        CIN.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                CINMouseReleased(evt);
            }
        });
        CIN.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CINActionPerformed(evt);
            }
        });
        CIN.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                CINKeyPressed(evt);
            }
        });
        jPanel1.add(CIN);
        CIN.setBounds(350, 20, 160, 30);

        affi.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Buttons/afficher.png"))); // NOI18N
        affi.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                affiMouseReleased(evt);
            }
        });
        jPanel1.add(affi);
        affi.setBounds(600, 10, 140, 50);

        cin.setFont(new java.awt.Font("Waree", 1, 14)); // NOI18N
        cin.setText("CIN :");
        jPanel1.add(cin);
        cin.setBounds(10, 80, 70, 30);

        nom.setFont(new java.awt.Font("Waree", 1, 14)); // NOI18N
        nom.setText("Nom :");
        jPanel1.add(nom);
        nom.setBounds(10, 150, 70, 30);

        prenom.setFont(new java.awt.Font("Waree", 1, 14)); // NOI18N
        prenom.setText("Prénom :");
        jPanel1.add(prenom);
        prenom.setBounds(10, 220, 80, 30);

        num.setFont(new java.awt.Font("Waree", 1, 14)); // NOI18N
        num.setText("N° Tele :");
        jPanel1.add(num);
        num.setBounds(10, 300, 80, 30);

        email.setFont(new java.awt.Font("Waree", 1, 14)); // NOI18N
        email.setText("Email :");
        jPanel1.add(email);
        email.setBounds(20, 380, 70, 30);

        marier.setFont(new java.awt.Font("Waree", 1, 14)); // NOI18N
        marier.setText("Marier :");
        jPanel1.add(marier);
        marier.setBounds(10, 440, 80, 30);

        CIN_Client.setBorder(null);
        jPanel1.add(CIN_Client);
        CIN_Client.setBounds(110, 80, 160, 30);

        Nom_Client.setBorder(null);
        jPanel1.add(Nom_Client);
        Nom_Client.setBounds(110, 150, 160, 30);

        Prenom_Client.setBorder(null);
        jPanel1.add(Prenom_Client);
        Prenom_Client.setBounds(110, 220, 160, 30);

        Numero_Tele_Client.setBorder(null);
        jPanel1.add(Numero_Tele_Client);
        Numero_Tele_Client.setBounds(110, 300, 160, 30);

        Email_Client.setBorder(null);
        jPanel1.add(Email_Client);
        Email_Client.setBounds(110, 380, 160, 30);

        oui.setText("Oui");
        jPanel1.add(oui);
        oui.setBounds(120, 440, 70, 30);

        non.setText("Non");
        non.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nonActionPerformed(evt);
            }
        });
        jPanel1.add(non);
        non.setBounds(210, 440, 90, 30);

        metier.setFont(new java.awt.Font("Waree", 1, 14)); // NOI18N
        metier.setText("Métier :");
        jPanel1.add(metier);
        metier.setBounds(470, 120, 90, 30);

        date.setFont(new java.awt.Font("Waree", 1, 14)); // NOI18N
        date.setText("Date de Naissance :");
        jPanel1.add(date);
        date.setBounds(380, 250, 170, 30);

        nom_en.setFont(new java.awt.Font("Waree", 1, 14)); // NOI18N
        nom_en.setText("N° Enfants :");
        jPanel1.add(nom_en);
        nom_en.setBounds(440, 330, 110, 40);

        Metier_Client.setBorder(null);
        Metier_Client.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Metier_ClientActionPerformed(evt);
            }
        });
        jPanel1.add(Metier_Client);
        Metier_Client.setBounds(560, 120, 160, 30);

        Date_Naissance_Client.setBackground(new java.awt.Color(255, 255, 255));
        Date_Naissance_Client.setDateFormatString("YYYY-MM-dd");
        jPanel1.add(Date_Naissance_Client);
        Date_Naissance_Client.setBounds(560, 250, 200, 30);

        Nombre_Enfant_Client.setBorder(null);
        jPanel1.add(Nombre_Enfant_Client);
        Nombre_Enfant_Client.setBounds(580, 340, 160, 30);

        jLabel11.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Labels/txt1.png"))); // NOI18N
        jPanel1.add(jLabel11);
        jLabel11.setBounds(100, 70, 230, 50);

        jLabel12.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Labels/txt1.png"))); // NOI18N
        jPanel1.add(jLabel12);
        jLabel12.setBounds(100, 140, 214, 50);

        jLabel13.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Labels/txt1.png"))); // NOI18N
        jPanel1.add(jLabel13);
        jLabel13.setBounds(100, 210, 214, 50);

        jLabel14.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Labels/txt1.png"))); // NOI18N
        jPanel1.add(jLabel14);
        jLabel14.setBounds(100, 290, 214, 50);

        jLabel15.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Labels/txt1.png"))); // NOI18N
        jPanel1.add(jLabel15);
        jLabel15.setBounds(100, 370, 214, 50);

        jLabel16.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Labels/txt1.png"))); // NOI18N
        jPanel1.add(jLabel16);
        jLabel16.setBounds(340, 10, 230, 50);

        jLabel17.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Labels/txt1.png"))); // NOI18N
        jPanel1.add(jLabel17);
        jLabel17.setBounds(550, 110, 214, 50);

        jLabel18.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Labels/txt1.png"))); // NOI18N
        jPanel1.add(jLabel18);
        jLabel18.setBounds(550, 240, 230, 50);

        jLabel19.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Labels/txt1.png"))); // NOI18N
        jPanel1.add(jLabel19);
        jLabel19.setBounds(550, 330, 214, 50);

        Enre.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Buttons/Enregistrer_Client.png"))); // NOI18N
        Enre.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                EnreMouseReleased(evt);
            }
        });
        jPanel1.add(Enre);
        Enre.setBounds(680, 430, 150, 50);

        cin_ar.setFont(new java.awt.Font("Amiri", 1, 16)); // NOI18N
        cin_ar.setForeground(new java.awt.Color(0, 0, 0));
        cin_ar.setText("الرقم الوطني :");
        jPanel1.add(cin_ar);
        cin_ar.setBounds(340, 80, 110, 30);

        nom_ar.setFont(new java.awt.Font("Amiri", 1, 16)); // NOI18N
        nom_ar.setForeground(new java.awt.Color(0, 0, 0));
        nom_ar.setText("النسب : ");
        jPanel1.add(nom_ar);
        nom_ar.setBounds(330, 150, 70, 30);

        afficher_ar.setFont(new java.awt.Font("Amiri", 1, 16)); // NOI18N
        afficher_ar.setForeground(new java.awt.Color(255, 255, 255));
        afficher_ar.setText("عرض");
        jPanel1.add(afficher_ar);
        afficher_ar.setBounds(200, 20, 80, 30);

        prenom_ar.setFont(new java.awt.Font("Amiri", 1, 16)); // NOI18N
        prenom_ar.setForeground(new java.awt.Color(0, 0, 0));
        prenom_ar.setText("الاسم :");
        jPanel1.add(prenom_ar);
        prenom_ar.setBounds(330, 220, 60, 30);

        num_ar.setFont(new java.awt.Font("Amiri", 1, 16)); // NOI18N
        num_ar.setForeground(new java.awt.Color(0, 0, 0));
        num_ar.setText("رقم الهاتف :");
        jPanel1.add(num_ar);
        num_ar.setBounds(330, 300, 90, 30);

        email_ar.setFont(new java.awt.Font("Amiri", 1, 16)); // NOI18N
        email_ar.setForeground(new java.awt.Color(0, 0, 0));
        email_ar.setText("البريد الالكتروني :");
        jPanel1.add(email_ar);
        email_ar.setBounds(330, 380, 140, 30);

        afficher_ar_back.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Buttons/afficher_.png"))); // NOI18N
        jPanel1.add(afficher_ar_back);
        afficher_ar_back.setBounds(140, 10, 160, 50);

        metier_ar.setFont(new java.awt.Font("Amiri", 1, 16)); // NOI18N
        metier_ar.setForeground(new java.awt.Color(0, 0, 0));
        metier_ar.setText("المهنة :");
        jPanel1.add(metier_ar);
        metier_ar.setBounds(790, 120, 70, 30);

        date_ar.setFont(new java.awt.Font("Amiri", 1, 16)); // NOI18N
        date_ar.setForeground(new java.awt.Color(0, 0, 0));
        date_ar.setText("تاريخ الازدياد :");
        jPanel1.add(date_ar);
        date_ar.setBounds(780, 250, 110, 30);

        nom_en_ar.setFont(new java.awt.Font("Amiri", 1, 16)); // NOI18N
        nom_en_ar.setForeground(new java.awt.Color(0, 0, 0));
        nom_en_ar.setText("عدد الاطفال :");
        jPanel1.add(nom_en_ar);
        nom_en_ar.setBounds(790, 340, 100, 30);

        enregistrer_ar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Buttons/save_ar.png"))); // NOI18N
        enregistrer_ar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                enregistrer_arMouseReleased(evt);
            }
        });
        jPanel1.add(enregistrer_ar);
        enregistrer_ar.setBounds(500, 430, 170, 50);

        marier_ar.setFont(new java.awt.Font("Amiri", 1, 16)); // NOI18N
        marier_ar.setForeground(new java.awt.Color(0, 0, 0));
        marier_ar.setText("الحالة العائلية :");
        jPanel1.add(marier_ar);
        marier_ar.setBounds(330, 440, 110, 40);

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Accueil/wallhaven-19788.jpg"))); // NOI18N
        jPanel1.add(jLabel1);
        jLabel1.setBounds(0, 0, 910, 510);

        jTabbedPane1.addTab("Infos de Client", jPanel1);

        jPanel3.setForeground(new java.awt.Color(255, 0, 0));
        jPanel3.setLayout(null);

        Etage_Chambre_Client.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2" }));
        jPanel3.add(Etage_Chambre_Client);
        Etage_Chambre_Client.setBounds(276, 128, 125, 24);

        Nom_Personne.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4" }));
        Nom_Personne.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                Nom_PersonneMouseReleased(evt);
            }
        });
        Nom_Personne.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Nom_PersonneActionPerformed(evt);
            }
        });
        jPanel3.add(Nom_Personne);
        Nom_Personne.setBounds(276, 238, 125, 24);

        Num_Chambre.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                Num_ChambreMouseReleased(evt);
            }
        });
        jPanel3.add(Num_Chambre);
        Num_Chambre.setBounds(276, 326, 125, 24);

        Etage_Chambre.setForeground(new java.awt.Color(255, 0, 0));
        jPanel3.add(Etage_Chambre);
        Etage_Chambre.setBounds(710, 140, 75, 31);

        Nombre_Personnes.setForeground(new java.awt.Color(255, 0, 0));
        jPanel3.add(Nombre_Personnes);
        Nombre_Personnes.setBounds(710, 230, 75, 30);

        Numero_Chambre.setForeground(new java.awt.Color(255, 0, 0));
        jPanel3.add(Numero_Chambre);
        Numero_Chambre.setBounds(710, 320, 75, 35);

        etage.setFont(new java.awt.Font("DejaVu Sans Condensed", 1, 14)); // NOI18N
        etage.setText("Etage du Chambre :");
        jPanel3.add(etage);
        etage.setBounds(59, 132, 141, 17);

        nom_per.setFont(new java.awt.Font("DejaVu Sans Condensed", 1, 14)); // NOI18N
        nom_per.setText("Nombre des Personnes :");
        jPanel3.add(nom_per);
        nom_per.setBounds(24, 242, 176, 17);

        num_ch.setFont(new java.awt.Font("DejaVu Sans Condensed", 1, 14)); // NOI18N
        num_ch.setText("N° Chambre :");
        jPanel3.add(num_ch);
        num_ch.setBounds(106, 330, 94, 17);

        montant.setFont(new java.awt.Font("DejaVu Sans Condensed", 1, 14)); // NOI18N
        montant.setText("Montant :");
        montant.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                montantMouseClicked(evt);
            }
        });
        jPanel3.add(montant);
        montant.setBounds(130, 383, 70, 30);

        txt1.setFont(new java.awt.Font("Dimnah", 1, 14)); // NOI18N
        txt1.setForeground(new java.awt.Color(102, 102, 102));
        txt1.setText("Informations réglable");
        jPanel3.add(txt1);
        txt1.setBounds(250, 30, 190, 28);

        txt2.setFont(new java.awt.Font("Dimnah", 1, 14)); // NOI18N
        txt2.setForeground(new java.awt.Color(102, 102, 102));
        txt2.setText("Les informations actuelles");
        jPanel3.add(txt2);
        txt2.setBounds(650, 30, 220, 28);

        TXT_MESSAGE.setFont(new java.awt.Font("DejaVu Sans Condensed", 1, 14)); // NOI18N
        jPanel3.add(TXT_MESSAGE);
        TXT_MESSAGE.setBounds(267, 383, 72, 28);

        enre.setFont(new java.awt.Font("DejaVu Sans Condensed", 1, 14)); // NOI18N
        enre.setForeground(new java.awt.Color(255, 255, 255));
        enre.setText("Enregistrer");
        jPanel3.add(enre);
        enre.setBounds(640, 440, 100, 30);

        jLabel41.setFont(new java.awt.Font("DejaVu Sans Condensed", 1, 14)); // NOI18N
        jLabel41.setText("DH");
        jPanel3.add(jLabel41);
        jLabel41.setBounds(340, 380, 21, 30);

        enre_back.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Buttons/save_.png"))); // NOI18N
        enre_back.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                enre_backMouseReleased(evt);
            }
        });
        jPanel3.add(enre_back);
        enre_back.setBounds(620, 440, 141, 37);

        txt4.setFont(new java.awt.Font("AlBattar", 1, 18)); // NOI18N
        txt4.setForeground(new java.awt.Color(102, 102, 102));
        txt4.setText("المعلومات الحالية");
        jPanel3.add(txt4);
        txt4.setBounds(680, 60, 190, 30);

        txt3.setFont(new java.awt.Font("AlBattar", 1, 18)); // NOI18N
        txt3.setForeground(new java.awt.Color(102, 102, 102));
        txt3.setText("المعلومات المعدلة ");
        jPanel3.add(txt3);
        txt3.setBounds(260, 60, 200, 30);

        etage_ar.setFont(new java.awt.Font("Amiri", 1, 16)); // NOI18N
        etage_ar.setForeground(new java.awt.Color(0, 0, 0));
        etage_ar.setText("الطابق :");
        jPanel3.add(etage_ar);
        etage_ar.setBounds(481, 129, 70, 30);

        nom_per_ar.setFont(new java.awt.Font("Amiri", 1, 16)); // NOI18N
        nom_per_ar.setForeground(new java.awt.Color(0, 0, 0));
        nom_per_ar.setText("عدد الاشخاص :");
        jPanel3.add(nom_per_ar);
        nom_per_ar.setBounds(480, 230, 100, 40);

        enr.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Buttons/save_ar.png"))); // NOI18N
        jPanel3.add(enr);
        enr.setBounds(40, 450, 170, 40);

        num_ch_ar.setFont(new java.awt.Font("Amiri", 1, 16)); // NOI18N
        num_ch_ar.setForeground(new java.awt.Color(0, 0, 0));
        num_ch_ar.setText("رقم الغرفة :");
        jPanel3.add(num_ch_ar);
        num_ch_ar.setBounds(480, 319, 80, 40);

        montant_ar.setFont(new java.awt.Font("Amiri", 1, 16)); // NOI18N
        montant_ar.setForeground(new java.awt.Color(0, 0, 0));
        montant_ar.setText("الثمن :");
        jPanel3.add(montant_ar);
        montant_ar.setBounds(490, 390, 50, 20);

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Accueil/wallhaven-19788.jpg"))); // NOI18N
        jPanel3.add(jLabel2);
        jLabel2.setBounds(0, 0, 930, 530);

        jTabbedPane1.addTab("Chambre Reservée", jPanel3);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 894, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 533, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    public void Traduire()
    {
        cin.setVisible(false);
        nom.setVisible(false);
        prenom.setVisible(false);
        num.setVisible(false);
        email.setVisible(false);
        marier.setVisible(false);
        metier.setVisible(false);
        date.setVisible(false);
        nom_en.setVisible(false);
        etage.setVisible(false);
        nom_per.setVisible(false);
        num_ch.setVisible(false);
        montant.setVisible(false);
        txt1.setVisible(false);
        txt2.setVisible(false);
        affi.setVisible(false);
        enre.setVisible(false);
        
        
        
        
        cin_ar.setVisible(true);
        nom_ar.setVisible(true);
        prenom_ar.setVisible(true);
        num_ar.setVisible(true);
        email_ar.setVisible(true);
        marier_ar.setVisible(true);
        metier_ar.setVisible(true);
        date_ar.setVisible(true);
        nom_en_ar.setVisible(true);
        etage_ar.setVisible(true);
        nom_per_ar.setVisible(true);
        num_ch_ar.setVisible(true);
        montant_ar.setVisible(true);
        txt3.setVisible(true);
        txt4.setVisible(true);
        enre.setText("حفظ المعومات");
        oui.setText("متزوج");
        non.setText("غير متزوج");
        afficher_ar.setVisible(true);
        afficher_ar_back.setVisible(true);
        enregistrer_ar.setVisible(true);
        enr.setVisible(true);
        
    }
    
    public void visibility()
    {
        cin_ar.setVisible(false);
        nom_ar.setVisible(false);
        prenom_ar.setVisible(false);
        num_ar.setVisible(false);
        email_ar.setVisible(false);
        marier_ar.setVisible(false);
        metier_ar.setVisible(false);
        date_ar.setVisible(false);
        nom_en_ar.setVisible(false);
        etage_ar.setVisible(false);
        nom_per_ar.setVisible(false);
        num_ch_ar.setVisible(false);
        montant_ar.setVisible(false);
        txt3.setVisible(false);
        txt4.setVisible(false);
        afficher_ar.setVisible(false);
        afficher_ar_back.setVisible(false);
        enregistrer_ar.setVisible(false);
        enr.setVisible(false);
        
    }
    
    private void enre_backMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_enre_backMouseReleased
        update_infos();
    }//GEN-LAST:event_enre_backMouseReleased

    private void montantMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_montantMouseClicked
        Obtenir_le_montant();
    }//GEN-LAST:event_montantMouseClicked

    private void Nom_PersonneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Nom_PersonneActionPerformed
        obtenir_info_chambre();
    }//GEN-LAST:event_Nom_PersonneActionPerformed

    private void Nom_PersonneMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Nom_PersonneMouseReleased
        obtenir_info_chambre();
    }//GEN-LAST:event_Nom_PersonneMouseReleased
    
    public void Enregistrer()
    {
        String cin =CIN.getText();

        try{

            String sql1 ="update client set NOM=?,PRENOM=?,NUMERO_TELE=?,EMAIL=?,SITUATION=?,DATE_NAISSANCE=?,METIER=?,NOMBRE_ENFANTS=? where CIN_CLIENT=+'"+cin+"'";

            //String sql2="insert into RESERVATION(CIN_CLIENT) values(?)";
            //String sql3="update dernier_update set CIN_CLIENT=? where ID_DERNIER=1";

            // inserer au table CLIENT
            PreparedStatement ps1 = conn.prepareStatement(sql1);

            ps1.setString(1, Nom_Client.getText());
            ps1.setString(2, Prenom_Client.getText());
            ps1.setString(3, Numero_Tele_Client.getText());
            ps1.setString(4, Email_Client.getText());
            ps1.setString(5, Status_Client());
            ps1.setString(6, ((JTextField)Date_Naissance_Client.getDateEditor().getUiComponent()).getText());
            ps1.setString(7, Metier_Client.getText());
            ps1.setInt(8,Nombre_Enfant());

            // Insertion dans la table CHAMBRE
            /*PreparedStatement ps2 = conn.prepareStatement(sql2);
            ps2.setString(1, CIN_Client.getText());*/

            //Insertion dans la table PAIEMENT
            //PreparedStatement ps3 = conn.prepareStatement(sql3);
            //ps3.setString(1, CIN_Client.getText());

            //execution des requetes
            ps1.executeUpdate();
            //ps2.executeUpdate();
            //s3.executeUpdate();
            //ps4.executeUpdate(sql4);

            JOptionPane.showMessageDialog(null,"Les information a enregistrer avec succes");

        }catch(SQLException | HeadlessException e)
        {

            JOptionPane.showMessageDialog(null,"Echec d'Insertion Client "+""+e.getMessage());

        }
    
    }
    private void EnreMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_EnreMouseReleased

        Enregistrer();
    }//GEN-LAST:event_EnreMouseReleased

    private void Metier_ClientActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Metier_ClientActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_Metier_ClientActionPerformed

    private void nonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nonActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_nonActionPerformed

    private void affiMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_affiMouseReleased

        Afficher();

    }//GEN-LAST:event_affiMouseReleased

    private void CINKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_CINKeyPressed
        if(evt.getKeyCode()==KeyEvent.VK_ENTER){
            Afficher();
        }
    }//GEN-LAST:event_CINKeyPressed

    private void CINActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CINActionPerformed

    }//GEN-LAST:event_CINActionPerformed

    private void CINMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CINMouseReleased
        CIN.setText("");
    }//GEN-LAST:event_CINMouseReleased

    private void Num_ChambreMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Num_ChambreMouseReleased
       Obtenir_le_montant();
    }//GEN-LAST:event_Num_ChambreMouseReleased

    private void enregistrer_arMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_enregistrer_arMouseReleased
         Enregistrer();
    }//GEN-LAST:event_enregistrer_arMouseReleased
    
    
    public String  Status_Client()
        {
            String marier ="";
                if(oui.isSelected())
                {
                    return  "Marié";
                }
                else if(non.isSelected()) {
                    
                    
                    return "non marié";
                    
                }
                else{
                
                    JOptionPane.showMessageDialog(null, "Error");
                }
        return null;
                
                
        }
        
        public int Nombre_Enfant()
        {
        
            if(oui.isSelected())
            {
                return Integer.parseInt(Nombre_Enfant_Client.getText());
            }
            else if(non.isSelected())
            {
                return 0;
            }
        return 0;
        }
        
        
        
        
private void Afficher()
        {
        
                  
        String cin =CIN.getText();
        ResultSet rs01;
        
        try {
            
            String sql="select * from client where CIN_CLIENT='"+cin+"'";
            String sql_modifier="select * from reservation where CIN_CLIENT='"+cin+"'";
            //String sql3="select * from CHAMBRE where CIN_CLIENT='"+cin+"'";
            
            PreparedStatement ps1 = conn.prepareStatement(sql);
            PreparedStatement ps2 = conn.prepareStatement(sql_modifier);
            //PreparedStatement ps3= conn.prepareStatement(sql3);
            rs=ps1.executeQuery();
            rs01=ps2.executeQuery();
           if(rs.next())
                {
                 
                    // --------------- Client ------------------------------
                    String cin_=rs.getString("CIN_CLIENT");
                    CIN_Client.setText(cin_);
                    
                    String nom=rs.getString("NOM");
                    Nom_Client.setText(nom);
                    
                    String prenom=rs.getString("PRENOM");
                    Prenom_Client.setText(prenom);
                    
                    String num=rs.getString("NUMERO_TELE");
                    Numero_Tele_Client.setText(num);
                    
                    String email=rs.getString("EMAIL");
                    Email_Client.setText(email);
                    
                    String situation=rs.getString("SITUATION");
                    if(null != situation)
                        switch (situation) {
                    case "Marié":
                        oui.setSelected(true);
                        break;
                    case "non marié":
                        non.setSelected(true);
                        break;
                        
                    
                // -------------------------------------------------        
                    
                }
                if(rs01.next())
                    {
                        
                        int Etage=rs01.getInt("ETAGE_CHAMBRE");
                        
                        Etage_Chambre.setText(Integer.toString(Etage));
                        
                        int Num_Personne =rs01.getInt("TYPE_CHAMBRE");
                        
                        Nombre_Personnes.setText(Integer.toString(Num_Personne));
                        
                        int num_chambre =rs01.getInt("NUM_CHAMBRE");
                        
                        Numero_Chambre.setText(Integer.toString(num_chambre));
                        
                    }
               
                    Date date_naiss=rs.getDate("DATE_NAISSANCE");
                    Date_Naissance_Client.setDate(date_naiss);
                    
                    String metier=rs.getString("METIER");
                    Metier_Client.setText(metier);
                    
                    String nbr_enf=rs.getString("NOMBRE_ENFANTS");
                    Nombre_Enfant_Client.setText(nbr_enf);
                    
                    
                    
                    
                    
                }
            
           else{
            JOptionPane.showMessageDialog(null, "Ce CIN n'existe pas ! \n Essayer avec une autre");
           }
            
        } catch (SQLException | HeadlessException e) {
            JOptionPane.showMessageDialog(null, e);
        }
        
        
        } 





    private void update_infos()
        {
              
        
        String cin =CIN.getText();
       
         try{
                        
                        String sql0 ="update reservation set NUM_CHAMBRE=?,TYPE_CHAMBRE=?,ETAGE_CHAMBRE=? where CIN_CLIENT=+'"+cin+"'";
                        String sql_up="update chambre set STATUS_CHAMBRE=? where NUMERO_CHAMBRE=?";


                        // Mettre a jour la table Reservation
                        PreparedStatement ps0 = conn.prepareStatement(sql0); 
                        
                        String sql_chambre="update chambre set STATUS_CHAMBRE=? where NUMERO_CHAMBRE=?";            
                        PreparedStatement ps1 = conn.prepareStatement(sql_chambre); 
                        ps1.setString(1, "oui");
                        ps1.setInt(2, Integer.parseInt( Num_Chambre.getSelectedItem().toString()));   
                        
                        // Mettre a jour la table Chambre        
                        PreparedStatement ps2 = conn.prepareStatement(sql_up); 
                        ps2.setString(1, "non");
                        
                        ps2.setInt(2, Integer.parseInt( Numero_Chambre.getText().toString()));      
                        
                        
                        
                                 ps0.setInt(1, Integer.parseInt( Num_Chambre.getSelectedItem().toString()));
                                 ps0.setInt(2, Integer.parseInt( Nom_Personne.getSelectedItem().toString()));
                                 ps0.setInt(3, Integer.parseInt( Etage_Chambre_Client.getSelectedItem().toString()));
                            
                          
                       
                        
                        
                        
                        ps0.executeUpdate();
                        ps1.executeUpdate();
                        ps2.executeUpdate();
                        JOptionPane.showMessageDialog(null, "la modification a été effectuer avec succe");
                        
         }catch(SQLException | NumberFormatException e)
         {
             JOptionPane.showMessageDialog(null, e.getMessage());
         }
        
        
        }
    
        
    private void Obtenir_le_montant()
    {
    
        
        
            try{ 
                    String sql_montant = "select * from montant where ETAGE_CHAMBRE=? and TYPE_CHAMBRE=? and NUM_CHAMBRE=?";
                    PreparedStatement ps_montant=conn.prepareStatement(sql_montant);
                    ps_montant.setInt(1,Integer.parseInt(Etage_Chambre_Client.getSelectedItem().toString()));
                    ps_montant.setInt(2,Integer.parseInt(Nom_Personne.getSelectedItem().toString()));
                    ps_montant.setInt(3,Integer.parseInt(Num_Chambre.getSelectedItem().toString()));

                    rs=ps_montant.executeQuery();
                    while(rs.next())
                        {

                            int montant =rs.getInt("MONTANT_CHAMBRE");
                            TXT_MESSAGE.setText(+montant+"");
                            System.out.println(montant);
                        }

            }catch(SQLException | NumberFormatException e)
             {
                 JOptionPane.showMessageDialog(null, e.getMessage());

             }
    
    }
    
    private void obtenir_info_chambre()
    {
        int num_cham=0;
        try {
            
            String sql0="select * from chambre where ETAGE_CHAMBRE=? and TYPE_CHAMBRE=? and STATUS_CHAMBRE=?";
            
            PreparedStatement ps0 = conn.prepareStatement(sql0);
            ps0.setInt(1, Integer.parseInt(Etage_Chambre_Client.getSelectedItem().toString()));
            ps0.setInt(2, Integer.parseInt(Nom_Personne.getSelectedItem().toString()));
            ps0.setString(3, "non");
            ResultSet rs0 ;
            rs0=ps0.executeQuery();
            Num_Chambre.removeAllItems();
            while(rs0.next())
                {   
                    num_cham =rs0.getInt("NUMERO_CHAMBRE");
                    Num_Chambre.addItem(num_cham);
                    
                }
            
            
        } catch (SQLException | NumberFormatException e) {
            JOptionPane.showMessageDialog(null, e.getMessage());
        }
            
    }
    
    

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField CIN;
    private javax.swing.JTextField CIN_Client;
    private com.toedter.calendar.JDateChooser Date_Naissance_Client;
    private javax.swing.JTextField Email_Client;
    private javax.swing.JLabel Enre;
    private javax.swing.JLabel Etage_Chambre;
    private javax.swing.JComboBox Etage_Chambre_Client;
    private javax.swing.JTextField Metier_Client;
    private javax.swing.JTextField Nom_Client;
    private javax.swing.JComboBox Nom_Personne;
    private javax.swing.JTextField Nombre_Enfant_Client;
    private javax.swing.JLabel Nombre_Personnes;
    private javax.swing.JComboBox Num_Chambre;
    private javax.swing.JLabel Numero_Chambre;
    private javax.swing.JTextField Numero_Tele_Client;
    private javax.swing.JTextField Prenom_Client;
    private javax.swing.JLabel TXT_MESSAGE;
    private javax.swing.JLabel affi;
    private javax.swing.JLabel afficher_ar;
    private javax.swing.JLabel afficher_ar_back;
    private javax.swing.JLabel cin;
    private javax.swing.JLabel cin_ar;
    private javax.swing.JLabel date;
    private javax.swing.JLabel date_ar;
    private javax.swing.JLabel email;
    private javax.swing.JLabel email_ar;
    private javax.swing.JLabel enr;
    private javax.swing.JLabel enre;
    private javax.swing.JLabel enre_back;
    private javax.swing.JLabel enregistrer_ar;
    private javax.swing.JLabel etage;
    private javax.swing.JLabel etage_ar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel41;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JLabel marier;
    private javax.swing.JLabel marier_ar;
    private javax.swing.JLabel metier;
    private javax.swing.JLabel metier_ar;
    private javax.swing.JLabel montant;
    private javax.swing.JLabel montant_ar;
    private javax.swing.JLabel nom;
    private javax.swing.JLabel nom_ar;
    private javax.swing.JLabel nom_en;
    private javax.swing.JLabel nom_en_ar;
    private javax.swing.JLabel nom_per;
    private javax.swing.JLabel nom_per_ar;
    private javax.swing.JRadioButton non;
    private javax.swing.JLabel num;
    private javax.swing.JLabel num_ar;
    private javax.swing.JLabel num_ch;
    private javax.swing.JLabel num_ch_ar;
    private javax.swing.JRadioButton oui;
    private javax.swing.JLabel prenom;
    private javax.swing.JLabel prenom_ar;
    private javax.swing.JLabel txt1;
    private javax.swing.JLabel txt2;
    private javax.swing.JLabel txt3;
    private javax.swing.JLabel txt4;
    // End of variables declaration//GEN-END:variables
}
